package com.oro.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;

/**
 * Entity implementation class for Entity: Telephone
 * 
 */
@Entity
public class Telephone implements Serializable {

	@Transient
	private static final List<String> countries = new ArrayList<String>() {
		private static final long serialVersionUID = 1L;
		{
			add(Telephone.COUNTRY_NOT_SPECIFIED);
			add(Telephone.COUNTRY_AU);
			add(Telephone.COUNTRY_IT);
		}
	};
	@Transient
	public static final String COUNTRY_AU = "AU";
	@Transient
	public static final String COUNTRY_IT = "IT";
	@Transient
	public static final String COUNTRY_NOT_SPECIFIED = "Not specified";
	private static final long serialVersionUID = 1L;
	@Transient
	public static final String TYPE_FAX = "Fax";
	@Transient
	public static final String TYPE_GENERIC = "Generic";
	@Transient
	public static final String TYPE_HOME = "Home";
	@Transient
	public static final String TYPE_MOBILE = "Mobile";
	@Transient
	public static final String TYPE_OTHER = "Other";
	@Transient
	public static final String TYPE_WORK = "Work";

	@Transient
	private static final List<String> types = new ArrayList<String>() {
		private static final long serialVersionUID = 1L;
		{
			add(Telephone.TYPE_HOME);
			add(Telephone.TYPE_MOBILE);
			add(Telephone.TYPE_WORK);
			add(Telephone.TYPE_FAX);
			add(Telephone.TYPE_GENERIC);
			add(Telephone.TYPE_OTHER);
		}
	};

	public static List<String> getCountries() {
		return countries;
	}

	public static String getCountryAu() {
		return COUNTRY_AU;
	}

	public static String getCountryIt() {
		return COUNTRY_IT;
	}

	public static String getCountryNotSpecified() {
		return COUNTRY_NOT_SPECIFIED;
	}

	public static String getTypeGeneric() {
		return TYPE_GENERIC;
	}

	public static String getTypeHome() {
		return TYPE_HOME;
	}

	public static String getTypeMobile() {
		return TYPE_MOBILE;
	}

	public static String getTypeOther() {
		return TYPE_OTHER;
	}

	public static List<String> getTypes() {
		return types;
	}

	public static String getTypeWork() {
		return TYPE_WORK;
	}

	private String country;

	@Id
	@GeneratedValue
	private Long id;

	private String number;

	private String type;

	public Telephone() {
		super();
		this.type = Telephone.TYPE_GENERIC;
		this.type = Telephone.COUNTRY_NOT_SPECIFIED;
	}

	public Telephone(String number) {
		this();
		this.number = number;
	}

	public Telephone(String number, String type) {
		this();
		this.number = number;
		this.type = type;
	}

	public Telephone(String number, String type, String country) {
		this();
		this.number = number;
		this.type = type;
		this.country = country;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null)
			return false;
		if (!(o instanceof Telephone))
			return false;
		Telephone t = (Telephone) o;
		if (getId() != null && getId() != 0L)
			return getId().equals(t.getId());
		if (getNumber() != null)
			return getNumber().equals(t.getNumber());
		return t.getNumber() == null;
	}

	public String getCountry() {
		return this.country;
	}

	public Long getId() {
		return id;
	}

	public String getNumber() {
		return this.number;
	}

	public String getType() {
		return this.type;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public void setType(String type) {
		this.type = type;
	}
}
